<template>
    <el-date-picker
            v-model="currentValue"
            :disabled="disabled"
            type="daterange"
            class="commonRangeDate"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            @change="onChange"
            size="small"
            :clearable="true"
            range-separator="至"
            value-format="yyyy-MM-dd"
            :style="{'max-width':width+'px'}"
    >
    </el-date-picker>
</template>
<script>
//    import Utils from '../../../js/util'
    export default {
        currentValue: String,
        oldValue: String,

        data() {
            return {
                currentValue: this.value,
            };
        },

        watch: {
            value(val, oldValue) {
                this.setCurrentValue(val);
            },
        },



        created: function () {

        },

        methods: {
            setCurrentValue(val) {
                this.currentValue = val;
            },

            handleClick(evt) {
                this.$emit('click', evt);
            },

            onChange() {
                const me = this;
//                let result = [];
//                if (me.currentValue && me.currentValue.length > 0) {
//                    for (let d in me.currentValue) {
//                        result.push(Utils.formatDate.format(me.currentValue[d]));
//                    }
//                }
//                me.$emit('input', result);
//                me.$emit('value', result);
                me.$emit('input', me.currentValue);
                me.$emit('value', me.currentValue);
            },
        },

        props: {
            placeholder: {
                type: String,
                default: ''
            },
            value: {
                type: [String, Array]
            },
            width:{
                type: Number,
                default: 220
            },
            disabled: {
                type: Boolean,
                default: false
            }
        },
    }
</script>
